package com.study.project.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Api(tags = "WEB-测试权限")
@Controller
public class testRole {

    @ApiOperation(value = "有权限")
    @GetMapping("test01")
    @ResponseBody
    public String in01() {
        Subject subject = SecurityUtils.getSubject();
        if (subject.hasRole("vip10")) {
            return "你是Vip会员,请进去消费！";
        } else {
            return "你不是Vip会员,请先办理Vip！";
        }
    }
    @ApiOperation(value = "无权限")
    @GetMapping("test02")
    @ResponseBody
    public String in02() {
        Subject subject = SecurityUtils.getSubject();
        if (subject.hasRole("贵族vip10")) {
            return "你是贵族Vip10,请进去消费！";
        } else {
            return "你不是贵族Vip10,不能进去！";
        }
    }
}
